package com.jsz.yun.ai.field.service.impl;

import com.jsz.yun.ai.field.domainservice.UserFileDomainService;
import com.jsz.yun.ai.field.entity.UserEntity;
import com.jsz.yun.ai.field.entity.UserFileEntity;
import com.jsz.yun.ai.field.service.UserFileService;
import com.jsz.yun.ai.field.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author gaoxing
 * @date 2025-03-28 16:34:11
 */
@Service
@Slf4j
public class UserFileServiceImpl implements UserFileService {

    @Resource
    UserFileDomainService userFileDomainService;

    @Resource
    UserInfoService userInfoService;
    @Override
    public UserFileEntity uploadFile(MultipartFile file) {
        // 先查询用户剩余空间大小
        UserEntity user = userInfoService.validateUserDiskSize(file.getSize());
        // 文件进行上传
        return userFileDomainService.uploadFile(file,user.getUserName());
    }
}
